<?php
/**
 * User: YL
 * Date: 2019/09/12
 */

namespace restful\commands;

use Illuminate\Console\GeneratorCommand;
use restful\commands\traits\GeneratorCommandInit;
use restful\commands\traits\GetStudPath;

class MakeService extends GeneratorCommand
{
    use GeneratorCommandInit;
    use GetStudPath;

    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'make:service';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Create a new service class';

    /**
     * The type of class being generated.
     *
     * @var string
     */
    protected $type = 'Service';

    /**
     * Get the stub file for the generator.
     *
     * @return string
     */
    protected function getStub()
    {
        return $this->getStudPath('service.stud');
    }

    /**
     * Get the default namespace for the class.
     *
     * @param  string  $rootNamespace
     * @return string
     */
    protected function getDefaultNamespace($rootNamespace)
    {
        if ($this->option('module')) {
            return $rootNamespace . '\Http\\' . ucfirst($this->option('module')) . '\Services';
        }

        return $rootNamespace.'\Http\Services';
    }
}
